package com.gzhu.knowledgeAdmin.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gzhu.knowledgeAdmin.dao.BillMapper;
import com.gzhu.knowledgeAdmin.entity.Bill;
import com.gzhu.knowledgeAdmin.service.BillService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements BillService {
    @Resource
    private BillMapper billMapper;

    @Override
    public List<Bill> getBill(String fGsid) {

        List<Bill> bills = billMapper.getBill(fGsid);
        for(Bill bill : bills)
        {
            bill.setAiwhjfze(bill.getAiwhjfsc() * bill.getAiwhdj());
            bill.setYytzjfze(bill.getYytzjfsc() * bill.getYytzdj());
            bill.setAizxsfze(bill.getAizxs() * bill.getAizxdj());
            bill.setRgzxjfze(bill.getRgzxs() * bill.getRgzxdj());
            bill.setRgjtjfze(bill.getRgwhjfsc() * bill.getRgwhdj());
            bill.setDxjfze(bill.getDxjfs() * bill.getDxdj());

            float totalAmount = bill.getAiwhjfze() + bill.getYytzjfze() + bill.getAizxsfze() + bill.getRgzxjfze() + bill.getRgjtjfze() + bill.getDxjfze();
            bill.setZjfje(totalAmount);
            //减免金额，可自定义规则，暂定为0
            float discountAmount = 0;
            bill.setJmze(discountAmount);

            bill.setYsze(bill.getZjfje() - bill.getJmze());
        }
        return bills;
    }
}
